package com.asdf.db.operations.stat;

import java.util.List;

import com.asdf.db.operations.IDBOperation;
import com.asdf.db.results.ResultStatus;
import com.asdf.db.results.stat.StatResult;
import com.asdf.external.DBUsageDetails;

/** Operation for inserting a new usage statistics.
 * @author so4i2014
 *
 */
public class InsertStat implements IDBOperation<StatResult>
{
	private List<DBUsageDetails> source = null;
	private DBUsageDetails item = null;
	
	/** Create a new operation.
	 * @param source - A list we gonna insert into.
	 */
	public InsertStat(List<DBUsageDetails> source)
	{
		super();
		this.source = source;
	}

	/** Set the stats item to insert.
	 * @param item
	 */
	public void setDBUsageDetails(DBUsageDetails item)
	{
		this.item = item;
	}
	
	/* (non-Javadoc)
	 * @see com.asdf.db.operations.IDBOperation#perform()
	 */
	@Override
	public StatResult perform()
	{
		StatResult result = new StatResult( );

		source.add(item);
		result.setStatus(ResultStatus.OK);
		return result;
	}
}
